package string;

import java.util.Scanner;

public class StringDemo06 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String email;
        do {
            System.out.print("输入邮箱地址：");
            email = in.nextLine();
            //检查email的正确性
        }while (email == null ||
                email.trim().equals("") ||
                email.indexOf("@")==-1);
        //得到正确的email
        int index = email.indexOf("@");
        String name = email.substring(0, index);
        String host = email.substring(index+1);
        System.out.println(name);
        System.out.println(host);
    }
}
